<template>
  <div class="app-container">
    <ht-table
      ref="dataTable"
      :showSerialNumber="false"
      :multi-select="false"
      :dictMap="dictMap"
      :reqConfig="reqConfig"
      :queryParams="queryParams"
      :tableBindColumns="tableBindColumns"
      rowKey="sysCode"
      defaultEventKey="entryTable"
    >
      <template v-slot:operate>
        <el-table-column label="操作" align="center" width="200" fixed="right" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <ht-button-group
              :buttonList="[
                {
                  label: '登录',
                  visible: scope.row.opType === 'OT01',
                  // permission: 'user:xxx:xxx',
                  doFunc: () => {
                    handleAction('login', scope.row);
                  },
                },
                {
                  label: '退出',
                  visible: scope.row.opType === 'OT00',
                  // permission: 'user:xxx:xxx',
                  doFunc: () => {
                    handleAction('logout', scope.row);
                  },
                },
                {
                  label: '查询',
                  visible: true,
                  // permission: 'user:xxx:xxx',
                  doFunc: () => {
                    handleAction('query', scope.row);
                  },
                },
              ]"
            />
          </template>
        </el-table-column>
      </template>
    </ht-table>
    <!-- 登录/退出/查询弹出框 -->
    <log-dialog
      ref="logDialog"
      :dictMap="dictMap"
      :formData.sync="formData"
      :dialogType="dialogType"
      :titleTxt="titleTxt"
      @editComplete="editComplete"
    ></log-dialog>
  </div>
</template>
<script>
import { apiUrlConfig } from "@/api/cnaps/ccms/805/login_or_logout_entry.js";
import { listPageMixin } from "@/libs/listPageMixin";
import logDialog from "./components/logEntryDialog.vue";

export default {
  name: "LoginOrLogoutEntry",
  mixins: [listPageMixin],
  components: {
    logDialog,
  },
  data() {
    return {
      dialogType: 0,
      reqConfig: apiUrlConfig,
      //数据字典
      searchFormDictList: ["SYS_CODE", "LOGINOPERATIONTYPECODE"],
      //  明细弹框数据
      // form表单字段
      formData: {
        sysCode: "",
        curSysStatus: "",
        remarks: "",
      },
      showSearch: true,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
      },
      tableBindColumns: [
        {
          label: `系统编号`,
          prop: "sysCode",
          dictCode: "SYS_CODE",
          align: "center",
        },
        {
          label: `网点号`,
          prop: "orgCode",
          align: "center",
        },
        {
          label: `系统当前日期`,
          prop: "oriSysDate",
          align: "center",
          type: "date",
        },
        {
          label: `系统状态`,
          prop: "opType",
          dictCode: "LOGINOPERATIONTYPECODE",
          align: "center",
        },
      ],
    };
  },
  mounted() {},
  methods: {
    editComplete(state) {
      if (state) {
        this.$refs.dataTable.doQuery();
      }
    },
    /** 按钮操作 */
    handleAction(type, row = {}) {
      switch (type) {
        case "login":
          // 登录
          this.dialogType = 0;
          this.titleTxt = '登录申请录入';
          this.formData = _.clone(row);
          this.formData.curSysStatus = "OT00";
          this.$refs.logDialog.show();
          break;
        case "logout":
          // 退出
          this.dialogType = 1;
          this.titleTxt = '退出申请录入';
          this.formData = _.clone(row);
          this.formData.curSysStatus = "OT01";
          this.$refs.logDialog.show();
          break;
        case "query":
          // 查询
          this.dialogType = 2;
          this.titleTxt = '查询申请录入';
          this.formData = _.clone(row);
          this.formData.curSysStatus = "OT02";
          this.$refs.logDialog.show();
          break;
      }
    },
  },
};
</script>
<style>
.label-header-msg {
  font-weight: bold;
}
</style>
